<template>
  <div
      :class="['zdp-tag', `zdp-tag--${size}`, `zdp-tag--${type}`]"
      :style="{ backgroundColor: color }"
      @click="handleClick"
  >
    <span class="zdp-tag__text">
      <slot>{{ text }}</slot>
    </span>
  </div>
</template>

<script setup>
import { defineProps, defineEmits } from 'vue';

// 定义 Props
const props = defineProps({
  text: {
    type: String,
    default: '',
  },
  type: {
    type: String,
    default: 'default', // 支持 default, primary, success, warning, danger
  },
  color: {
    type: String,
    default: '',
  },
  size: {
    type: String,
    default: 'medium', // 支持 small, medium, large
  },
});

// 定义 Emits
const emit = defineEmits(['click']);

// 点击标签
const handleClick = () => {
  emit('click');
};
</script>

<style scoped>
.zdp-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-right: 8px;
  margin-bottom: 8px;
}

.zdp-tag--small {
  font-size: 12px;
  padding: 2px 6px;
}

.zdp-tag--medium {
  font-size: 14px;
  padding: 4px 8px;
}

.zdp-tag--large {
  font-size: 16px;
  padding: 6px 10px;
}

.zdp-tag--default {
  background-color: #666;
}

.zdp-tag--primary {
  background-color: #409eff;
}

.zdp-tag--success {
  background-color: #67c23a;
}

.zdp-tag--warning {
  background-color: #e6a23c;
}

.zdp-tag--danger {
  background-color: #f56c6c;
}
</style>